#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int run(int y)
{
	if (y%400==0&&(y%4==0&&y%100!=0))
	{
		return 1;
	}
	else
	{
		return 0;
	}
}
int days(int y1, int m1)
{
	int d[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	int day = d[m1];
		if (run(y1) && m1 == 2)
			day += 1;
	return day;
}

int main()
{
	int y, m;
	scanf("%d%d",&y,&m);
	printf("%d", days(y, m));
	return 0;
}